#include <gps.h>
#ifndef _MAIN_H_
#define _MAIN_H_

#define _USE_MATH_DEFINES

#define WAYPOINT 1
#define HEADING 2
#define HALT 3
#define ATSPEED 4
#define ATHEADINGSPEED 5
#define ATHEADINGSPEEDMIXED 6
#define ATOBSAVOID 7
#define ATOBSAVOIDNAIVE 8
#define ATOBSAVOIDHEADING 9
#define ATSTEPPER 10 

#define MAX_LINE 256
#define MAX_ARGS 4

#define secsPerLog 5

#define LENGTH 2000
#define WIDTH 300
#define SPREAD 450
#define TOLERANCE 100
#define TRAVEL 30

struct boat{
	int state;
	bool commandStarted;
	int command;
	double commandArgs[MAX_ARGS];
	gps_data_t current;
        double lastLat, lastLon;
	double retHeading, retPitch, retRoll, retTemp;
	bool goodData;
	double tempProbe;
};

struct obsLink{
/*    
    unsigned int startIndex;
    unsigned int startValue;
    double startHeading;
    unsigned int endIndex;
    unsigned int endValue;
    double endHeading;
    struct obsLink *next;
*/
    VECTOR start;
    VECTOR end;
};

int init();
double calcDistance(double lat1, double lon1, double lat2, double lon2);
double calcHeading(double lat1, double lon1, double lat2, double lon2);
void signal_handler(int signum);
int getCommand();
int parseCommand();
void printStatus();
void printLog();
void fetchSick();
void newPoint(double lat, double lon, double bearing, double distance, VECTOR *newP);
void *stepperInit(void *vargp);
void *stepperRotate(void *vargp);

#endif
